{extend name="public/base"}

{block name="title"}
经销商申请
{/block}

{block name="style"}
{css href="/static/wechat/css/index.css" /}
{css href="/static/wechat/popo1/css/shop.css" /}
<style type="text/css">
    .g-scsfz-div{
        height: 13.5rem;
        background-color: #ffffff;
        display: flex;
        flex-wrap: wrap;
        /* justify-content: space-around; */
        align-items: center;
    }
    .scsfz{
        width: 40%;
        height: 6rem;
        /*background-color: #333333;*/
        margin: 0px .64rem;
        text-align: center;
    }
    .scsfz>i{
        position: relative;
        display: block;
        width: 100%;
        height: 80%;
        background-size: 100% 100%;
    }
    .sczmsfz{
        background-size: 100% 100%;
    }
    .scsfz3{
        float: left;
        position: absolute;
        margin-right: 9px;
        margin-bottom: 9px;
        width: 50px;
        height: 50px;
        border-radius: 100%;
        border: 1px solid #d9d9d9;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        margin: auto;
        background-color: #ffffff;
    }
    .weui-uploader__input-box:before{
        width: 2px;
        height: 25.5px;
        background-color: #40a8ff;
    }
    .weui-uploader__input-box:after {
        width: 25.5px;
        height: 2px;
        background-color: #40a8ff;
    }
    .sczmsfz{
        background: url(/static/wechat/images/weirenzhen_03.png);
    }
    .zmsfz{
        background: url(/static/wechat/images/weirenzheng_05.png);
    }
    .sfzfm{
        background: url(/static/wechat/images/weirenzheng_09.png);
    }
    .img_yyzz{
        background: url(/static/wechat/images/shop_ying_03.jpg);
    }
    .weui-popup__overlay {
        opacity: 1;
    }
    /*添加图片*/
    #addimg{
        width: 43%;
        height: 18%;
        margin: auto;
        position: absolute;
        right: 5%;
        opacity: 0;
    }
    .navbar{
        position: relative;
        width: 100%;
        height: 25rem;
        background-color: #FFFFFF;
    }
    .tjimg>img{
        width: 3.5rem;
        height: 3.5rem;
        margin: 15px 0px 0px 20px;
        float: left;
    }
    #marg{
        margin: 15px 0px 0px 20px;
    }
    .tjtu{
        display: block;
        width: 85%;
        border: none;
        height: 2rem;
        margin: 0 auto;
        margin-top: 19rem;
        color: #ffffff;
        background-color: #fc4208;
        border-radius: 5px;
    }
</style>
{/block}

{block name="body"}
<form action="{:url('certification')}" id="audit_form">
<div class="pageControl1 startShop bg-f8">
    <div class="nav">
        <div class="msui_navTop">
            <a class="msui_navTop-back" href="javascript:;" style="display: none;"><i class="micon-back_ff6"></i></a>
            <h1 class="msui_navTop-title">商家入驻</h1>
        </div>
    </div>
    <div class="prove active">
        <div class="weui-cell bg-f8">
            <p class="weui-cell__hd cl-3333">店铺信息</p>
        </div>
        <div class="weui-cell bg-ff">
            <p class="weui-label cl-3333">店铺logo</p>
            <a href="#" class="list_img weui-cell__bd">
                <img id="uploaderInput0_img" src="{$dealer.logo|get_img_url}" style="width:auto; margin-left: 0;" alt=""/>
                <input id="uploaderInput0" class="weui-uploader__input" type="file" accept="image/*"  file-attr="" />
                <input name="logo" type="hidden" value="{$dealer.logo|default=''}" />
            </a>
        </div>
        <div class="weui-cell bg-ff">
            <div class="weui-cell__hd">
                <label class="weui-label cl-3333">店铺名称</label>
            </div>
            <div class="weui-cell__bd">
                <input name="dealer_name" value="{$dealer.dealer_name|default=''}" type="text" class="weui-input" placeholder="请输入店铺名称"/>
            </div>
        </div>
        <div class="weui-cells bg-ff">
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">联系电话</label>
                </div>
                <div class="weui-cell__bd">
                    <input name="phone" value="{$dealer.phone ? $dealer.phone :  $Think.session.phone}" type="number" class="weui-input" placeholder="请输入电话号码"/>
                </div>
            </div>
            <!--<div class="weui-cell weui-cell_access">-->
                <!--<div class="weui-cell__hd">-->
                    <!--<label class="weui-label cl-3333">店铺地区</label>-->
                <!--</div>-->
                <!--<div class="weui-cell__bd">-->
                    <!--<input  class="weui-input" id="contact_address" type="text"  placeholder="省、市、区/县"  data-code="{$dealer.area|default=''}" data-codes=""/>-->
                    <!--<input type="hidden" name="contact_address">-->
                <!--</div>-->
                <!--<div class="weui-cell__ft"></div>-->
            <!--</div>-->
            <!--<div class="weui-cell weui-cell_access">-->
                <!--<div class="weui-cell__hd">-->
                    <!--<label class="weui-label cl-3333">街道</label>-->
                <!--</div>-->
                <!--<div class="weui-cell__bd">-->
                    <!--<select class="weui-select" name="street" style="width: 80%; font-size: .7rem; height: inherit; line-height: inherit;">-->
                        <!--<option>请选择</option>-->
                    <!--</select>-->
                <!--</div>-->
                <!--<div class="weui-cell__ft"></div>-->
            <!--</div>-->
            <!--<div class="weui-cell weui-cell_access shop_site">-->
                <!--<div class="weui-cell__hd">-->
                    <!--<label class="weui-label cl-3333">详细地址</label>-->
                <!--</div>-->
                <!--<div class="weui-cell__bd">-->
                    <!--<input name="address" type="text" class="weui-input" placeholder="请输入详细地址" value="{$dealer.address|default=''}" />-->
                    <!--<img id="box_map_open" src="/static/wechat/images/shop_logo_07.jpg" alt="" />-->
                <!--</div>-->
            <!--</div>-->
            <input type="hidden" name="province" value="" />
            <input type="hidden" name="city" value="" />
            <input type="hidden" name="area" value="" />
            <input type="hidden" name="street" value="" />
            <!--联系地址-->
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">店铺地区</label>
                </div>
                <div class="weui-cell__bd">
                    <input  class="weui-input" id="contact_address" type="text" readonly />
                </div>
            </div>
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">街道</label>
                </div>
                <div class="weui-cell__bd">
                    <input  class="weui-input" id="street" type="text" readonly />
                </div>
            </div>
            <div class="weui-cell weui-cell_access shop_site">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">详细地址</label>
                </div>
                <div class="weui-cell__bd">
                    <input name="address" type="text" class="weui-input" placeholder="请输入详细地址" value="{$partner.address|default=''}" />
                    <img id="box_map_open" src="/static/wechat/images/shop_logo_07.jpg" alt="" style="width: 2rem;" />
                </div>
            </div>
        </div>
        <div class="weui-cells">
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">店铺门面</label>
                </div>
                <div class="weui-cell__bd">
                    <a id="s_menmian" href="javascript:;" class="weui-input open-popup" style="display:block;color:#999;width:100%;" data-target="#Popup1" >请上传（选填）</a>
                    <!--<input id="s_menmian" type="text" class="weui-input open-popup" data-target="#Popup1" placeholder="请上传（选填）" readonly />-->
                </div>

            </div>
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">环境图</label>
                </div>
                <div class="weui-cell__bd">
                    <a id="s_huanjing" href="javascript:;" class="weui-input open-popup" style="display:block;color:#999;width:100%;" data-target="#Popup2" >请上传（选填）</a>
                    <!--<input id="s_huanjing" type="text" class="weui-input open-popup" data-target="#Popup2" placeholder="请上传（选填）" readonly />-->
                </div>
            </div>
        </div>
        <div class="weui-cells">
            <div class="weui-cell bg-f7">
                <div class="weui-cell__bd">
                    <p>意向区域</p>
                </div>
            </div>
            <div class="weui-cell weui-cell_access" style="padding: 15px;">
                <div class="weui-cell__hd">
                    <p class="weui-label">意向等级</p>
                </div>
                <div class="weui-cell__bd store_input">
                    <input name="level" class="weui-input" value="" type="text" id='picker' placeholder="请选择等级"/>
                </div>
                <div class="weui-cell__ft"></div>
            </div>
            <div class="weui-cell weui-cell_access" href="javascript:;" style="padding: 15px;">
                <div class="weui-cell__hd">
                    <p class="weui-label">意向区域</p>
                </div>
                <div class="weui-cell__bd store_input">
                    <input class="weui-input" id="start1" type="text" placeholder="省、市、区/县">
                    <input type="hidden" name="duty_area">
                </div>
                <div class="weui-cell__ft"></div>
            </div>
            <div class="weui-cells">
                <div class="weui-cell weui-cell_access">
                    <div class="weui-cell__hd">
                        <p class="weui-label">代理授权书</p>
                    </div>
                    <div class="weui-cell__bd store_input">
                        <a id="collecting_note" type="text" class="weui-input open-popup" style="display:block;color:#999;width:100%;"  data-target="#Popup3">请上传（选填）</a>
                    </div>
                    <div class="weui-cell__ft"></div>
                </div>
            </div>
        </div>

        <div class="weui-cell bg-f8">
            <p class="weui-cell__hd cl-3333">资质信息</p>
        </div>
        <div class="weui-cell bg-ff">
            <div class="weui-cell__hd">
                <label class="weui-label cl-3333">姓名</label>
            </div>
            <div class="weui-cell__bd">
                <input name="proposer" type="text" class="weui-input" placeholder="请输入您身份证上的姓名" value="{$dealer.proposer|default=''}" />
            </div>
        </div>
        <div class="weui-cell bg-ff">
            <div class="weui-cell__hd">
                <label class="weui-label cl-3333">身份证号</label>
            </div>
            <div class="weui-cell__bd">
                <input name="card_no" type="text" class="weui-input" placeholder="请输入您的身份证号" value="{$dealer.card_no|default=''}" />
            </div>
        </div>
        <div class="weui-cell bg-f8">
            <p class="weui-cell__hd cl-3333">身份证照片</p>
        </div>
        <div class="shop_card_img bg-ff">
            <div class="g-scsfz-div">
                <div class="scsfz">
                    <i class="sczmsfz" {notempty name='dealer.id_card_in_hand'}style="background:url({$dealer.id_card_in_hand}) no-repeat"{/notempty}>
                    <div class="weui-uploader__input-box scsfz3">
                        <input id="uploaderInput1" class="weui-uploader__input one_upload" type="file" accept="image/*" file-attr="" />
                        <input type="hidden" name="id_card_in_hand" value="{$dealer.id_card_in_hand|default=''}" />
                    </div>
                    </i>
                    <p>手持身份证正面照片</p>
                </div>

                <div class="scsfz">
                    <i class="zmsfz" {notempty name='dealer.id_card_front'}style="background:url({$dealer.id_card_front}) no-repeat"{/notempty} >
                    <div class="weui-uploader__input-box scsfz3">
                        <input id="uploaderInput2" class="weui-uploader__input one_upload" type="file" accept="image/*"  file-attr="" />
                        <input type="hidden" name="id_card_front" value="{$dealer.id_card_front|default=''}" />
                    </div>
                    </i>
                    <p>身份证正面照片</p>
                </div>

                <div class="scsfz" style="margin-top: -1rem;">
                    <i class="sfzfm" {notempty name='dealer.id_card_verso'}style="background:url({$dealer.id_card_verso}) no-repeat"{/notempty} >
                    <div class="weui-uploader__input-box scsfz3">
                        <input id="uploaderInput3" class="weui-uploader__input one_upload" type="file" accept="image/*"  file-attr="" />
                        <input type="hidden" name="id_card_verso" value="{$dealer.id_card_verso|default=''}" />
                    </div>
                    </i>
                    <p>身份证反面照片</p>
                </div>
            </div>
        </div>
        <div class="weui-cell"></div>
        <div class="weui-cell bg-ff">
            <div class="weui-cell__hd">
                <label class="weui-label cl-3333">注册号</label>
            </div>
            <div class="weui-cell__bd">
                <input name="business_license_num" type="text" class="weui-input" placeholder="请输入营业执照的注册号" value="{$dealer.business_license_num|default=''}" />
            </div>
        </div>
        <div class="weui-cell bg-ff">
            <div class="weui-cell__hd">
                <label class="weui-label cl-3333">执照名称</label>
            </div>
            <div class="weui-cell__bd">
                <input name="business_license_name" type="text" class="weui-input" placeholder="请输入营业执照名称" value="{$dealer.business_license_name|default=''}" />
            </div>
        </div>
        <div class="weui-sell_card bg-ff">
            <div class="weui-cell__hd">
                <label class="weui-label cl-3333">营业执照照片</label>
            </div>

            <div class="scsfz">
                <i class="img_yyzz" {notempty name='dealer.business_license'}style="background-image:url({$dealer.business_license})"{/notempty} >
                <div class="weui-uploader__input-box scsfz3">
                    <input id="uploaderInput4" class="weui-uploader__input one_upload" type="file" accept="image/*"  file-attr="" />
                    <input type="hidden" name="business_license" value="{$dealer.business_license|default=''}" />
                </div>
                </i>
            </div>
        </div>
        <input name="lat" type="hidden" value="{$dealer.lat|default=''}" />
        <input name="lon" type="hidden" value="{$dealer.lon|default=''}" />
        <input name="id" value="{$dealer.id|default=0}" type="hidden" />
        <div class="shop_btn shop_card_btn">
            <p>提交资质的好处</p>
            <p class="cl-9999">*摩邦优先推荐，更多流量支持</p>
            <p class="cl-9999">*认证信息展示，客户更多信任</p>
            <a href="javascript:;" class="weui-btn" id="s_btn_submit">提交审核</a>
        </div>
    </div>
</div>
<!--弹出框-->
<div id="Popup1" class="weui-popup__container popup-bottom">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="navbar">
            <div class="msui_nav msui_navTop" style="border-bottom: 1px solid #cccccc;">
                <a class="msui_navTop-back" onclick="$('#Popup1 .weui-popup__overlay').trigger('click');"><i class="micon-back"></i></a>
                <h1 class="msui_navTop-title">店铺门面</h1>
            </div>
            <div class="tjimg">
                <div class="shop_succ">
                    <div class="shop_store_img">
                        <div class="shop_store_img1">
                            <div class="scsfz" style="width:100%;height:9rem;margin:0;">
                                <i class="img_menmian" {notempty name='dealer.cover'}style="height:100%;background-image:url({$dealer.cover})"{else}style="height:100%;"{/notempty} >
                                <div class="weui-uploader__input-box scsfz3">
                                    <input id="uploaderInput_1" class="weui-uploader__input one_upload" type="file" accept="image/*"  file-attr="" />
                                    <input type="hidden" name="cover" value="{$dealer.cover}" />
                                </div>
                                </i>
                            </div>
                        </div>
                    </div>
                    <div class="shopStart_txt shopStart_txt_top">
                        <p class="cl-3333" style="text-align:left;text-indent:1.6rem;">请上传清晰的门店招牌图片，招牌要与商家名称一致，不要有水印，LOGO，二维码，地址，电话等。不要上传效果图或PS图等非真实图片</p>
                    </div>
                    <div class="shop_btn shopStart_btn">
                        <a href="javascript:;" onclick="$('#Popup1 .weui-popup__overlay').trigger('click');" class="weui-btn">确定</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="Popup2" class="weui-popup__container popup-bottom">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="navbar">
            <div class="msui_nav msui_navTop" style="border-bottom: 1px solid #cccccc;">
                <a class="msui_navTop-back" onclick="$('#Popup2 .weui-popup__overlay').trigger('click');"><i class="micon-back"></i></a>
                <h1 class="msui_navTop-title">添加图片</h1>
            </div>
            <div class="tjimg">
                {notempty name='dealer.environment_img1'}
                <img src="{$dealer.environment_img1|get_img_url}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                {notempty name='dealer.environment_img2'}
                <img src="{$dealer.environment_img2|get_img_url}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                {notempty name='dealer.environment_img3'}
                <img src="{$dealer.environment_img3|get_img_url}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                {notempty name='dealer.environment_img4'}
                <img src="{$dealer.environment_img4|get_img_url}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                {notempty name='dealer.environment_img5'}
                <img src="{$dealer.environment_img5|get_img_url}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                <div class="weui-uploader__input-box" id="marg">
                    <input id="uploaderInput_2" class="weui-uploader__input" type="file" accept="image/*"  file-attr="" />
                </div>
            </div>
            <input name="environment_img1" type="hidden" value="{$dealer.environment_img1|default=''}" />
            <input name="environment_img2" type="hidden" value="{$dealer.environment_img2|default=''}" />
            <input name="environment_img3" type="hidden" value="{$dealer.environment_img3|default=''}" />
            <input name="environment_img4" type="hidden" value="{$dealer.environment_img4|default=''}" />
            <input name="environment_img5" type="hidden" value="{$dealer.environment_img5|default=''}" />

            <button class="tjtu" onclick="$('#Popup2 .weui-popup__overlay').trigger('click');return false;">确认</button>
            <p style="clear:both;text-align:center;font-size:12px;color:#999;line-height:1rem;">（长按图片删除）</p>
        </div>
    </div>
</div>
<div id="Popup3" class="weui-popup__container popup-bottom">
        <div class="weui-popup__overlay"></div>
        <div class="weui-popup__modal">
            <div class="navbar">
                <div class="msui_nav msui_navTop" style="border-bottom: 1px solid #cccccc;">
                    <a class="msui_navTop-back" onclick="$('#Popup1 .weui-popup__overlay').trigger('click');"><i class="micon-back"></i></a>
                    <h1 class="msui_navTop-title">代理授权书</h1>
                </div>
                <div class="tjimg">
                    <div class="shop_succ">
                        <div class="shop_store_img">
                            <div class="shop_store_img1">
                                <div class="scsfz" style="width:100%;height:9rem;margin:0;">
                                    <i class="img_menmian" {notempty name='dealer.collecting_note'}style="height:100%;background-image:url({$dealer.collecting_note})"{else}style="height:100%;"{/notempty} >
                                    <div class="weui-uploader__input-box scsfz3">
                                        <input id="uploaderInput_3" class="weui-uploader__input one_upload" type="file" accept="image/*"  file-attr="" />
                                        <input type="hidden" name="collecting_note" value="{$dealer.collecting_note|default=''}" />
                                    </div>
                                    </i>
                                </div>
                            </div>
                        </div>
                        <div class="shopStart_txt shopStart_txt_top">
                            <p class="cl-3333" style="text-align:left;text-indent:1.6rem;">请上传代理授权书</p>
                        </div>
                        <div class="shop_btn shopStart_btn">
                            <a href="javascript:;" onclick="$('#Popup1 .weui-popup__overlay').trigger('click');" class="weui-btn">确定</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
<!-- loading toast -->
<div id="loadingToast" style="display:none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast" style="opacity: 1; visibility: visible;">
        <i class="weui-loading weui-icon_toast"></i>
        <p class="weui-toast__content">加载中...</p>
    </div>
</div>

<!--map-->
<div id="box_map" style="display:none;position:fixed;top:0;left:0;z-index:9999;width:100%;height:100%;">
    <div id="container" tabindex="0" style="display:block;position:absolute;top:0;left:0;z-index:9999;width:100%;height:100%;"></div>
    <img id="box_map_close" src="/static/wechat/images/radio.png" style="position:absolute;right:10px;bottom:10px;z-index:9999;width: 2rem;height: 2rem;" />
    <img src="http://webapi.amap.com/theme/v1.3/markers/n/mark_r.png" style="display:block;position:absolute;top:50%;left:50%;z-index:9999;width:19px;height:31px;margin:-31px 0 0 -9px;" />
</div>
{/block}
{block name="javascript"}
<script>
    $(function () {
//        $("#contact_address").val("{$dealer.r_province|default=''} {$dealer.r_city|default=''} {$dealer.r_area|default=''}").data('codes', "{$dealer.province|default=0},{$dealer.city|default=0},{$dealer.area|default=0}");
//        $("input[name='contact_address']").val("{$dealer.province|default=0},{$dealer.city|default=0},{$dealer.area|default=0}");

        $("#start1").val("{$dealer.dap_province|default=''} {$dealer.dac_city|default=''} {$dealer.dae_area|default=''}").attr('data-codes', "{$dealer.da_province|default=0},{$dealer.da_city|default=0},{$dealer.da_area|default=0}");
        $("input[name='duty_area']").val("{$dealer.da_province|default=0},{$dealer.da_city|default=0},{$dealer.da_area|default=0}");

        var levels = ['', '省', '市', '区/县'];
        var level = {$dealer.level|default=1};
        $("input[name='level']").val(levels[level]);
    });
</script>
{js href="/static/wechat/jquery_weui/js/data-picker1.js" /}
{js href="/static/wechat/jquery_weui/js/city-picker.js" /}
{js href="/static/wechat/popo1/js/shop.js" /}
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=9a8d0d7e358d9d80f7f61a1989ba35a0"></script>

<script>
    $("#start1").cityPicker({
        title: "选择意向区域",
        onChange: function (picker, values, displayValues) {
            var _picker = $("#picker").val();
            switch (_picker) {
                case '省':
                    displayValues.splice(1,2);
                    break;
                case '市':
                    displayValues.splice(2,1);
                    break;
                default:
                    break;
            }
            $("#start1").val(displayValues.join(" "));
        }
    });

    $("#contact_address").cityPicker({
        title: "选择联系地址",
        onChange: function (picker, values, displayValues) {
        }
    });

//    var _is_contact_address = true;
//    $("#contact_address").change(function () {
//        _is_contact_address=true;
//    });
//    get_street();
//    $(document).on('click', ".picker-button:first", function () {
//        get_street()
//    });
//
//    function get_street() {
//        if (_is_contact_address) {
//            $('.weui-toast__content').html('获取数据...');
//            $('#loadingToast').fadeIn();
//            var area = $("#contact_address").attr('data-code');
//            console.log(area);
//            var street = '{$dealer.street|default=0}';
//            if (!area) {
//                $('#loadingToast').fadeOut();
//                return false;
//            }
//            $.get("{:url('wechat/base/get_street')}", {area: area}, function (msg) {
//                $('#loadingToast').fadeOut();
//                var html = [];
//                var data = msg.data;
//                var len = data.length;
//                html.push("<option>请选择</option>");
//                for (var i = 0; i < len; i++) {
//                    if (data[i].region_id == street)
//                        html.push("<option value='"+ data[i].region_id +"' selected>"+ data[i].region_name +"</option>");
//                    else
//                        html.push("<option value='"+ data[i].region_id +"'>"+ data[i].region_name +"</option>");
//                }
//                $("select[name='street']").html(html.join(''));
//            }, 'json');
//        }
//        _is_contact_address = false;
//    }

    //长按删除图片
    function del_uploads_img(o){
        window.t_img = o;
        window.t_uploads = setTimeout(function(){
            if(window.confirm("确定删除?")){
                var formData = new Object();
                formData.img = '/uploads/'+window.t_img.src.split('/uploads/')[1];
                $.ajax({
                    url: '{:url("Base/del_upload_img")}' ,
                    type: 'POST',
                    data: formData,
                    dataType:"json",
                    success: function (d) {
                        if(d.code==200){
                            window.t_img.parentNode.removeChild(window.t_img);
                        }else{
                            var code = d.code;
                            $.alert(error_code[code]);
                        }
                    },
                    error: function (d) {
                        alert('网络异常');
                    }
                });

            }
        },666);
    }
    //取消长按删除图片
    function del_uploads_img_clear(){
        window.clearTimeout(window.t_uploads);
    }

    //处理定位信息
    function onComplete(data){
        //point	Point	坐标点。
        //accuracy	Number	定位精确程度，单位为米。

        if(data.info=="SUCCESS"){
            //alert($('input[name="lat"]').val() + '==' + $('input[name="lon"]').val());
            if (!$('input[name="lat"]').val())
                $('input[name="lat"]').val(data.position.lat);

            if (!$('input[name="lon"]').val())
                $('input[name="lon"]').val(data.position.lng);

            map_get_address();
        }
    }

    //处理定位出错信息
    function onError(e){
        return false;
    }

    function map_get_address(){
        $('#loadingToast').fadeIn();
        $.ajax({
            type:"get",
            cache:false,
            dataType:"json",
            url:"{:url('base/map_get_address')}?lat="+$('input[name="lat"]').val()+"&lng="+$('input[name="lon"]').val(),
            error:function(s){
                $('#loadingToast').fadeOut();
            },
            success:function(d) {
                $('#loadingToast').fadeOut();
                window.console.log(d);
                if (d.status == 1) {
                    var address_array = d.regeocode.addressComponent;
                    $('input[name="province"]').val(address_array.province);
                    $('input[name="city"]').val(address_array.city);
                    $('input[name="area"]').val(address_array.district);
                    $('input[name="street"]').val(address_array.township);
                    var tmpAddress = d.regeocode.formatted_address;//.split(d.regeocode.addressComponent.township)[1];
                    $('#contact_address').val(address_array.province + address_array.city + address_array.district);
                    $('#street').val(address_array.township);

                    var newstr = tmpAddress.replace(address_array.province + address_array.city + address_array.district + address_array.township, "");
                    $('input[name="address"]').val(newstr);
                } else {
                    alert(d.info);
                }
            }
        });
    }

    //上传门面和环境图片 相应的文本框应该修改placeholder来提示
    var uploads_placeholder = window.setInterval(function(){
        if($('input[name="cover"]').val()){
            $('#s_menmian').text("(已上传)");
        }
        if($("#Popup2 .tjimg img").length>0){
            $('#s_huanjing').text("(已上传"+$("#Popup2 .tjimg img").length+"张)");
        }else{
            $('#s_huanjing').text("请上传（选填）");
        }
        if($('input[name="collecting_note"]').val()){
            $('#collecting_note').text("(已上传)");
        }
    },999);

    $(function () {

        //地图选择定位经纬度
        $('#box_map_open').click(function(){
            $('#box_map').css("display","block");
            $('#box_map').css("height",$(window).height());
        });
        $('#box_map_close').click(function(){
            $('#box_map').css("display","none");
        });
        $('#contact_address').click(function () {
            $('#box_map').css("display","block");
            $('#box_map').css("height",$(window).height());
        });
        $('#street').click(function () {
            $('#box_map').css("display","block");
            $('#box_map').css("height",$(window).height());
        });


        //初始化地图
        mapObj = new AMap.Map('container',{
            resizeEnable: true,
            zoom: 15,
            //zoomEnable: false,	//禁止放大缩小
            //dragEnable: false,	//禁止拖动
            mapStyle:'fresh'
        });

        if($('input[name="id"]').val() == 0) {
            //监控用户位置
            mapObj.plugin('AMap.Geolocation', function () {
                geolocation = new AMap.Geolocation({
                    enableHighAccuracy: true,//是否使用高精度定位，默认:true
                    timeout: 30000,          //超过30秒后停止定位，默认：无穷大
                    maximumAge: 0,           //定位结果缓存0毫秒，默认：0
                    convert: true,           //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
                    showButton: true,        //显示定位按钮，默认：true
                    buttonPosition: 'LB',    //定位按钮停靠位置，默认：'LB'，左下角
                    buttonOffset: new AMap.Pixel(10, 10),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
                    showMarker: true,        //定位成功后在定位到的位置显示点标记，默认：true
                    showCircle: false,        //定位成功后用圆圈表示定位精度范围，默认：true
                    panToLocation: true,     //定位成功后将定位到的位置作为地图中心点，默认：true
                    zoomToAccuracy: true,      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
                    extensions: 'base'
                });
                //markerOptions: window.my_dingdan,
                mapObj.addControl(geolocation);//开始监控
                AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息//onComplete
                AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
                $(".amap-geo").trigger("click");
            });
        }else{
            if($('input[name="lat"]').val()>0 && $('input[name="lon"]').val()>0){
                mapObj.setCenter(new AMap.LngLat($('input[name="lon"]').val(),$('input[name="lat"]').val()));
                map_get_address();
            }
        }


        //开始拖拽地图时
        mapObj.on("dragstart", function(){
            window.clearTimeout(window.dragTime);
        });
        //拖拽地图过程中
        mapObj.on("dragging", function(){
            //window.clearTimeout(window.dragTime);

        });
        //停止拖拽地图时
        mapObj.on("dragend", function(){
            window.dragTime = setTimeout(function() {
                var tmp = mapObj.getCenter();console.log(tmp);
                $('input[name="lat"]').val(tmp.lat);
                $('input[name="lon"]').val(tmp.lng);
                map_get_address();
            },666);
        });


        $("#uploaderInput0").change(function(){
            $('#loadingToast').fadeIn();
            window.setTimeout(function(){
                var formData = new FormData();
                formData.append("type","logo");
                formData.append("img",$("#uploaderInput0")[0].files[0]);
                $.ajax({
                    url: '{:url("Base/get_upload_img")}' ,
                    type: 'POST',
                    data: formData,
                    async: false,
                    cache: true,
                    contentType: false,
                    processData: false,
                    dataType:"json",
                    success: function (d) {
                        if(!d.code){
                            alert(d.msg);
                        }else{
                            $("input[name='logo']").val(d.data.path);
                            $("#uploaderInput0_img").attr('src',SCOPE.image_host_url+d.data.path);
                        }
                        $('#loadingToast').fadeOut();
                    },
                    error: function (d) {
                        alert('网络异常');$('#loadingToast').fadeOut();
                    }
                });
            },666);

        });
        //添加图片
        $("#uploaderInput_2").change(function(){
            if($("#Popup2 .tjimg img").length>4){
                alert('只能添加5张图片');
            }else{
                $('#loadingToast').fadeIn();
                window.setTimeout(function(){
                    var formData = new FormData();
                    formData.append("type","dealer");
                    formData.append("img",$("#uploaderInput_2")[0].files[0]);
                    $.ajax({
                        url: '{:url("Base/get_upload_img")}' ,
                        type: 'POST',
                        data: formData,
                        async: false,
                        cache: true,
                        contentType: false,
                        processData: false,
                        dataType:"json",
                        success: function (d) {
                            if(!d.code){
                                alert(d.msg);
                            }else{
                                $("#Popup2 .tjimg").prepend('<img src="'+SCOPE.image_host_url+d.data.path+'" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />');
                            }
                            $('#loadingToast').fadeOut();
                        },
                        error: function (d) {
                            alert('网络异常');$('#loadingToast').fadeOut();
                        }
                    });
                },666);

            }
        });



        $("input.one_upload[type='file']").change(function () {
            upload_id_card($(this));
        });

        //  提交申请
        $("#s_btn_submit").click(function (e) {
            $('#loadingToast').fadeIn();
            $('.weui-toast__content').html('正在提交...');
            e.preventDefault();

            var tmpImg = $("#Popup2 .tjimg img");
            for(i=0;i<tmpImg.length;i++){
                $("input[name='environment_img"+(i+1)+"']").val( '/uploads/'+tmpImg[i].src.split('/uploads/')[1] );
            }
            //alert($("input[name='lat']").val() + '===' + $("input[name='lon']").val());
            $("input[name='duty_area']").val($('#start1').attr('data-codes'));
            //$("input[name='contact_address']").val($('#contact_address').attr('data-codes'));
            var _form = $("#audit_form");
            $.ajax({
                type : 'POST',
                url : _form.attr('action'),
                data : _form.serialize(),
                dataType : 'json',
                success : function (msg) {
                    $('#loadingToast').fadeOut();
                    //alert(msg);
                    console.log(msg);
                    if (msg.code == 200) {
                        var tmpUrl = "{:url('audit_status', ['status' => 1])}";
                        //alert(tmpUrl)
                        window.location.href=tmpUrl;
                    } else {
                        var code = msg.code;
                        $.alert(error_code[code]);
                    }
                }
            });
        });
    });

</script>
{/block}